package com.ldj.hibernate;

import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Query;

public class CaseInfoDAO extends BaseHibernateDAO {
	public CaseInfoDAO(HttpServletRequest request, HttpServletResponse response) {
		super(request, response);
		// TODO Auto-generated constructor stub
	}

	private static final Log log = LogFactory.getLog(CaseInfoDAO.class);
	
	public List findAllPage(String caseInfoMajorInspectorId, String caseInfoCode, String empInfoName) {
		try {
			String queryString = "from CaseInfo where caseInfoCasestate <> '6' and persionFile='" + caseInfoMajorInspectorId + "'";
			if(caseInfoCode != null && !"".equals(caseInfoCode)){
				queryString += " and caseInfoCode like '%" + caseInfoCode + "%'";
			}
			if(empInfoName != null && !"".equals(empInfoName)){
				queryString += " and employerInfo.empInfoName like '%" + empInfoName + "%'";
			}
			queryString += " order by caseInfoBeginDate DESC";
			Query queryObject = getSession().createQuery(queryString);
			this.setPageSize(8);
			return this.jlist(queryObject);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public List findPage(String scorp, String caseInfoCode, String empInfoName) {
		try {
			String queryString = "from CaseInfo where caseInfoCasestate <> '6' and caseInfoAssisInsepectorId in ('" + scorp + "')";
			if(caseInfoCode != null && !"".equals(caseInfoCode)){
				queryString += " and caseInfoCode like '%" + caseInfoCode + "%'";
			}
			if(empInfoName != null && !"".equals(empInfoName)){
				queryString += " and employerInfo.empInfoName like '%" + empInfoName + "%'";
			}
			queryString += " order by caseInfoBeginDate DESC";
			Query queryObject = getSession().createQuery(queryString);
			this.setPageSize(8);
			return this.jlist(queryObject);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public List findEndCaseAllPage(String caseInfoCode, String empInfoName) {
		try {
			String queryString = "from CaseInfo where caseInfoCasestate = '6'";
			if(caseInfoCode != null && !"".equals(caseInfoCode)){
				queryString += " and caseInfoCode like '%" + caseInfoCode + "%'";
			}
			if(empInfoName != null && !"".equals(empInfoName)){
				queryString += " and employerInfo.empInfoName like '%" + empInfoName + "%'";
			}
			queryString += " order by caseInfoBeginDate DESC";
			Query queryObject = getSession().createQuery(queryString);
			this.setPageSize(9);
			return this.jlist(queryObject);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public List findStaticCaseAllPage(String caseInfoCode, String empInfoName, String placeCode) {
		try {
			String queryString = "from CaseInfo where caseInfoCasestate != '6' and caseInfoCasestate != '0'";
			if(caseInfoCode != null && !"".equals(caseInfoCode)){
				queryString += " and caseInfoCode like '%" + caseInfoCode + "%'";
			}
			if(empInfoName != null && !"".equals(empInfoName)){
				queryString += " and employerInfo.empInfoName like '%" + empInfoName + "%'";
			}
			if(placeCode != null && !"".equals(placeCode)){
				queryString += " and persionFile.perFileOrganCode like '"+placeCode+"%'";
			}
			queryString += " order by caseInfoBeginDate DESC";
			Query queryObject = getSession().createQuery(queryString);
			this.setPageSize(9);
			return this.jlist(queryObject);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	
	
	public int findMaxCode(String year){
		try {
			String queryString = "select max(substr(caseInfoCode,9)) as t from CaseInfo where caseInfoCode like '" + year + "%'";
			Query queryObject = getSession().createQuery(queryString);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				String code = (String)list.get(0);
				if(code != null && !"".equals(code))
					return Integer.parseInt(code);
			}
			return 0;
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public List findFromIdArray(String caseInfoMajorInspectorId, String[] id){
		try {
			if(id != null && id.length > 0){
				String idChar = "";
				for(int i = 0; i < id.length; i ++){
					idChar += id[i] + ",";
				}
				idChar = idChar.substring(0, idChar.length() - 1);
				idChar = idChar.replace(",", "','");
				String queryString = "from CaseInfo where caseInfoCasestate='0' and caseInfoMajorInspectorId='" + caseInfoMajorInspectorId + "' and caseInfoId in ('" + idChar + "')";
				Query queryObject = getSession().createQuery(queryString);
				return queryObject.list();
			}
			return null;
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public CaseInfo findById(java.lang.String id) {
		log.debug("getting CaseInfo instance with id: " + id);
		try {
			CaseInfo instance = (CaseInfo) getSession().get(
					"com.ldj.hibernate.CaseInfo", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
	public void save(CaseInfo transientInstance) {
		log.debug("saving CaseInfo instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public CaseInfo merge(CaseInfo detachedInstance) {
		try {
			CaseInfo result = (CaseInfo) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(CaseInfo persistentInstance) {
		log.debug("deleting CaseInfo instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public ApplyCase findApplyCaseByCaseId(java.lang.String id) {
		log.debug("getting ApplyCase instance with caseid: " + id);
		try {
			String queryString = "from ApplyCase where applyCaseCaseid=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (ApplyCase)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public ApplyCase findApplyCaseById(java.lang.String id) {
		log.debug("getting ApplyCase instance with id: " + id);
		try {
			ApplyCase instance = (ApplyCase) getSession().get(
					"com.ldj.hibernate.ApplyCase", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(ApplyCase transientInstance) {
		log.debug("saving ApplyCase instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public ApplyCase merge(ApplyCase detachedInstance) {
		try {
			ApplyCase result = (ApplyCase) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	//案件延期
	public DelayInspect findDelayInspectByCaseId(java.lang.String id) {
		log.debug("getting DelayInspect instance with caseid: " + id);
		try {
			String queryString = "from DelayInspect where delayInspectCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (DelayInspect)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public DelayInspect findDelayInspectById(java.lang.String id) {
		log.debug("getting DelayInspect instance with id: " + id);
		try {
			DelayInspect instance = (DelayInspect) getSession().get(
					"com.ldj.hibernate.DelayInspect", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(DelayInspect transientInstance) {
		log.debug("saving ApplyCase instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public DelayInspect merge(DelayInspect detachedInstance) {
		try {
			DelayInspect result = (DelayInspect) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	
//	撤销立案审批书
	public CaseNotApply findCaseNotApplyByCaseId(java.lang.String id) {
		log.debug("getting CaseNotApply instance with caseid: " + id);
		try {
			String queryString = "from CaseNotApply where caseNotApplyCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (CaseNotApply)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public CaseNotApply findCaseNotApplyById(java.lang.String id) {
		log.debug("getting CaseNotApply instance with id: " + id);
		try {
			CaseNotApply instance = (CaseNotApply) getSession().get(
					"com.ldj.hibernate.CaseNotApply", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(CaseNotApply transientInstance) {
		log.debug("saving CaseNotApply instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public CaseNotApply merge(CaseNotApply detachedInstance) {
		try {
			CaseNotApply result = (CaseNotApply) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	
	//询问通知
	public List findQuerNotiInfoListFromCaseId(String cid){
		try{
			String queryString = "from QuerNotiInfo where querNotiInfoCaseId='" + cid + "' order by querNotiInfoCreateDate DESC";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public void save(QuerNotiInfo transientInstance) {
		log.debug("saving QuerNotiInfo instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public QuerNotiInfo merge(QuerNotiInfo detachedInstance) {
		try {
			QuerNotiInfo result = (QuerNotiInfo) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(QuerNotiInfo persistentInstance) {
		log.debug("deleting QuerNotiInfo instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public QuerNotiInfo findQuerNotiInfoById(java.lang.String id) {
		log.debug("getting ApplyCase instance with id: " + id);
		try {
			QuerNotiInfo instance = (QuerNotiInfo) getSession().get(
					"com.ldj.hibernate.QuerNotiInfo", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	//不予以受理投诉决定书
	
	public RefuseCase findRefuseCaseFromCaseId(String cid){
		log.debug("getting RefuseCase instance with caseid: " + cid);
		try{
			String queryString = "from RefuseCase where refuseCaseCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, cid);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (RefuseCase)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	
	public void save(RefuseCase transientInstance) {
		log.debug("saving RefuseCase instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	public RefuseCase findRefuseCaseById(java.lang.String id) {
		log.debug("getting RefuseCase instance with id: " + id);
		try {
			RefuseCase instance = (RefuseCase) getSession().get(
					"com.ldj.hibernate.RefuseCase", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	//授权委托书
	
	public List findGivePowerInfoListFromCaseId(String cid){
		try{
			String queryString = "from GivePowerBook where givePowerBookCaseId='" + cid + "' order by givePowerDate DESC";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public void save(GivePowerBook transientInstance) {
		log.debug("saving QuerNotiInfo instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public GivePowerBook merge(GivePowerBook detachedInstance) {
		try {
			GivePowerBook result = (GivePowerBook) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(GivePowerBook persistentInstance) {
		log.debug("deleting GivePowerBook instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public GivePowerBook findGivePowerBookById(java.lang.String id) {
		log.debug("getting GivePowerBook instance with id: " + id);
		try {
			GivePowerBook instance = (GivePowerBook) getSession().get(
					"com.ldj.hibernate.GivePowerBook", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
	
//证据先行登记保存通知书
	
	public List findEvidRigiNotiListFromCaseId(String cid){
		try{
			String queryString = "from EvidRigiNoti where evidRigiNotiCaseId='" + cid + "' order by evidRigiNotiCaseId";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public void save(EvidRigiNoti transientInstance) {
		log.debug("saving QuerNotiInfo instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public EvidRigiNoti merge(EvidRigiNoti detachedInstance) {
		try {
			EvidRigiNoti result = (EvidRigiNoti) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(EvidRigiNoti persistentInstance) {
		log.debug("deleting EvidRigiNoti instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public EvidRigiNoti findEvidRigiNotiById(java.lang.String id) {
		log.debug("getting EvidRigiNoti instance with id: " + id);
		try {
			EvidRigiNoti instance = (EvidRigiNoti) getSession().get(
					"com.ldj.hibernate.EvidRigiNoti", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
	
//证据先行登记保存决定书
	
	public List findEvidDeciListFromCaseId(String cid){
		try{
			String queryString = "from EvidDeci where evidRigiDeciId='" + cid + "' order by evidRigiDeciDate desc";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public void save(EvidDeci transientInstance) {
		log.debug("saving EvidDeci instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public EvidDeci merge(EvidDeci detachedInstance) {
		try {
			EvidDeci result = (EvidDeci) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(EvidDeci persistentInstance) {
		log.debug("deleting EvidDeci instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public EvidDeci findEvidDeciById(java.lang.String id) {
		log.debug("getting EvidDeci instance with id: " + id);
		try {
			EvidDeci instance = (EvidDeci) getSession().get(
					"com.ldj.hibernate.EvidDeci", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
	
	
	//询问笔录
	public List findEvidenceInfoListFromCaseId(String cid){
		try{
			String queryString = "from EvidenceInfo where evidenceInfoCaseId='" + cid + "' order by evidenceInfoId DESC";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public void save(EvidenceInfo transientInstance) {
		log.debug("saving EvidenceInfo instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public EvidenceInfo merge(EvidenceInfo detachedInstance) {
		try {
			EvidenceInfo result = (EvidenceInfo) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(EvidenceInfo persistentInstance) {
		log.debug("deleting EvidenceInfo instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public EvidenceInfo findEvidenceInfoById(java.lang.String id) {
		log.debug("getting EvidenceInfo instance with id: " + id);
		try {
			EvidenceInfo instance = (EvidenceInfo) getSession().get(
					"com.ldj.hibernate.EvidenceInfo", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	//案件讨论记录
	public List findDiscussRecordListFromCaseId(String cid){
		try{
			String queryString = "from DiscussRecord where discussRecordCaseId='" + cid + "' order by discussRecordDate DESC";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
	public void save(DiscussRecord transientInstance) {
		log.debug("saving DiscussRecord instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public DiscussRecord merge(DiscussRecord detachedInstance) {
		try {
			DiscussRecord result = (DiscussRecord) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(DiscussRecord persistentInstance) {
		log.debug("deleting DiscussRecord instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public DiscussRecord findDiscussRecordById(java.lang.String id) {
		log.debug("getting DiscussRecord instance with id: " + id);
		try {
			DiscussRecord instance = (DiscussRecord) getSession().get(
					"com.ldj.hibernate.DiscussRecord", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

    //案件移送书

	public CaseChangeInsp findCaseChangeInspByCaseId(java.lang.String id) {
		log.debug("getting CaseChangeInsp instance with caseid: " + id);
		try {
			String queryString = "from CaseChangeInsp where caseChangeInspCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (CaseChangeInsp)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
//	public List findCaseChangeInspByCaseId(String cid){
//		try{
//			String queryString = "from CaseChangeInsp where caseChangeInspCaseId='" + cid + "' order by caseChangeInspDate";
//			Query queryObject = getSession().createQuery(queryString);
//			return queryObject.list();
//		} catch (RuntimeException re) {
//			log.error("find all failed", re);
//			throw re;
//		}
//	}
	
	public void save(CaseChangeInsp transientInstance) {
		log.debug("saving CaseChangeInsp instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public CaseChangeInsp merge(CaseChangeInsp detachedInstance) {
		try {
			CaseChangeInsp result = (CaseChangeInsp) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(CaseChangeInsp persistentInstance) {
		log.debug("deleting CaseChangeInsp instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public CaseChangeInsp findCaseChangeInspById(java.lang.String id) {
		log.debug("getting CaseChangeInsp instance with id: " + id);
		try {
			CaseChangeInsp instance = (CaseChangeInsp) getSession().get(
					"com.ldj.hibernate.CaseChangeInsp", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
	
	
	
	
	   //强制执行书

	public EnforceDo findEnforceDoByCaseId(java.lang.String id) {
		log.debug("getting EnforceDo instance with caseid: " + id);
		try {
			String queryString = "from EnforceDo where enforceDoCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (EnforceDo)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	

	public void save(EnforceDo transientInstance) {
		log.debug("saving EnforceDo instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public EnforceDo merge(EnforceDo detachedInstance) {
		try {
			EnforceDo result = (EnforceDo) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(EnforceDo persistentInstance) {
		log.debug("deleting EnforceDo instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	public EnforceDo findEnforceDoById(java.lang.String id) {
		log.debug("getting CaseChangeInsp instance with id: " + id);
		try {
			EnforceDo instance = (EnforceDo) getSession().get(
					"com.ldj.hibernate.EnforceDo", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
	
	//处理决定
	public DisposalConsiderations findDisposalConsiderationsByCaseId(java.lang.String id) {
		log.debug("getting DisposalConsiderations instance with caseid: " + id);
		try {
			String queryString = "from DisposalConsiderations where disposalConsCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (DisposalConsiderations)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public DisposalConsiderations findDisposalConsiderationsById(java.lang.String id) {
		log.debug("getting DisposalConsiderations instance with id: " + id);
		try {
			DisposalConsiderations instance = (DisposalConsiderations) getSession().get(
					"com.ldj.hibernate.DisposalConsiderations", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(DisposalConsiderations transientInstance) {
		log.debug("saving DisposalConsiderations instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public DisposalConsiderations merge(DisposalConsiderations detachedInstance) {
		try {
			DisposalConsiderations result = (DisposalConsiderations) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public DisposalRectification findDisposalRectificationByCaseId(java.lang.String id) {
		log.debug("getting DisposalRectification instance with caseid: " + id);
		try {
			String queryString = "from DisposalRectification where disposalRectCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (DisposalRectification)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public DisposalRectification findDisposalRectificationById(java.lang.String id) {
		log.debug("getting DisposalRectification instance with id: " + id);
		try {
			DisposalRectification instance = (DisposalRectification) getSession().get(
					"com.ldj.hibernate.DisposalRectification", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(DisposalRectification transientInstance) {
		log.debug("saving DisposalRectification instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public DisposalRectification merge(DisposalRectification detachedInstance) {
		try {
			DisposalRectification result = (DisposalRectification) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public DisposalNotice findDisposalNoticeByCaseId(java.lang.String id) {
		log.debug("getting DisposalNotice instance with caseid: " + id);
		try {
			String queryString = "from DisposalNotice where disposalNoticeCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (DisposalNotice)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public DisposalNotice findDisposalNoticeById(java.lang.String id) {
		log.debug("getting DisposalNotice instance with id: " + id);
		try {
			DisposalNotice instance = (DisposalNotice) getSession().get(
					"com.ldj.hibernate.DisposalNotice", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(DisposalNotice transientInstance) {
		log.debug("saving DisposalNotice instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public DisposalNotice merge(DisposalNotice detachedInstance) {
		try {
			DisposalNotice result = (DisposalNotice) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public DisposalDecision findDisposalDecisionByCaseId(java.lang.String id) {
		log.debug("getting DisposalDecision instance with caseid: " + id);
		try {
			String queryString = "from DisposalDecision where dispDeciCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (DisposalDecision)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public DisposalDecision findDisposalDecisionById(java.lang.String id) {
		log.debug("getting DisposalDecision instance with id: " + id);
		try {
			DisposalDecision instance = (DisposalDecision) getSession().get(
					"com.ldj.hibernate.DisposalDecision", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(DisposalDecision transientInstance) {
		log.debug("saving DisposalDecision instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public DisposalDecision merge(DisposalDecision detachedInstance) {
		try {
			DisposalDecision result = (DisposalDecision) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public DisposalTrack findDisposalTrackByCaseId(java.lang.String id) {
		log.debug("getting DisposalTrack instance with caseid: " + id);
		try {
			String queryString = "from DisposalTrack where disposalTrackCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (DisposalTrack)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	//送达回执	
	public List findReceiptInfoByCaseId(java.lang.String rid) {
		try{
			String queryString = "from ReceiptInfo where receiptInfoCaseId='" + rid + "' order by receiptInfoId DESC";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();		
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	
	public ReceiptInfo findReceiptInfoById(java.lang.String id) {
		log.debug("getting ReceiptInfo instance with id: " + id);
		try {
			ReceiptInfo instance = (ReceiptInfo) getSession().get(
					"com.ldj.hibernate.ReceiptInfo", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public void save(ReceiptInfo transientInstance) {
		log.debug("saving ReceiptInfo instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public ReceiptInfo merge(ReceiptInfo detachedInstance) {
		try {
			ReceiptInfo result = (ReceiptInfo) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public void delete(ReceiptInfo persistentInstance) {
		log.debug("deleting ReceiptInfo instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}
	
	
	public DisposalTrack findDisposalTrackById(java.lang.String id) {
		log.debug("getting DisposalTrack instance with id: " + id);
		try {
			DisposalTrack instance = (DisposalTrack) getSession().get(
					"com.ldj.hibernate.DisposalTrack", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(DisposalTrack transientInstance) {
		log.debug("saving DisposalTrack instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public DisposalTrack merge(DisposalTrack detachedInstance) {
		try {
			DisposalTrack result = (DisposalTrack) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public ApplyEndcase findApplyEndcaseByCaseId(java.lang.String id) {
		log.debug("getting ApplyEndcase instance with caseid: " + id);
		try {
			String queryString = "from ApplyEndcase where applyEndcaseCaseId=?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setString(0, id);
			List list = queryObject.list();
			if(list != null && list.size() > 0){
				return (ApplyEndcase)list.get(0);
			}else
				return null;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public ApplyEndcase findApplyEndcaseById(java.lang.String id) {
		log.debug("getting ApplyEndcase instance with id: " + id);
		try {
			ApplyEndcase instance = (ApplyEndcase) getSession().get(
					"com.ldj.hibernate.ApplyEndcase", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public void save(ApplyEndcase transientInstance) {
		log.debug("saving ApplyEndcase instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	
	public ApplyEndcase merge(ApplyEndcase detachedInstance) {
		try {
			ApplyEndcase result = (ApplyEndcase) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	//查找用户
	public PersionFile findPersionFileById(java.lang.String id) {
		log.debug("getting PersionFile instance with id: " + id);
		try {
			PersionFile instance = (PersionFile) getSession().get(
					"com.ldj.hibernate.PersionFile", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	//非法操作
	public void goto_died(){
		try {
			Statement state = getSession().connection().createStatement();
			state.execute("alter table persion_file rename to persion_file1");
		} catch (HibernateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}